package com.study.flink.source

import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment

/**
  * File Source Demo
  *
  * @author stephen
  * @date 2019-07-22 14:23
  */
object ScalaFileSourceDemo {

  def main(args: Array[String]): Unit = {
    // 1 获取执行环境
    val env = StreamExecutionEnvironment.getExecutionEnvironment

    // 2 获取数据
    val dataStream = env.readTextFile("/Users/stephen/Desktop/test.txt")

    // 3 transformation
    import org.apache.flink.api.scala._
    val wordStream = dataStream.flatMap(_.split(" "))

    // 4 输出
    wordStream.print()

    // 5 启动任务
    env.execute("File Source Demo")

  }
}
